#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>


using namespace std;

int main()
{
  int pipefd[2]={0};
  int n = pipe(pipefd);
  if(n<0) return 1;
  cout<<"pipefd[0]:"<<pipefd[0]<<",pipefd[1]:"<<pipefd[1]<<endl;
 
  pid_t id=fork();
  if(id<0) return 2;
  if(id==0)
  {
    close(pipefd[0]);
    Wreter(pipefd[1]);
    close(1);
    exit(0);
  }
  close(pipefd[1]);
  pid_t rid=waitpid(id,nullptr,0);
  if(rid<0) return 3;

  Reader(pipefd[0]);
  
  return 0;
}
